package util.mongodb;

import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import util.mongodb.document.MongoDBDocument;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Gregory Boissinot
 */
public class SerializationInfo<T extends MongoDBDocument> {

    private final Map<Class<T>, JsonSerializer<T>> serializerMap;
    private final Map<Class<T>, JsonDeserializer<T>> deserializerMap;

    public SerializationInfo() {
        this.serializerMap = new HashMap<Class<T>, JsonSerializer<T>>();
        this.deserializerMap = new HashMap<Class<T>, JsonDeserializer<T>>();
    }

    public void addSerializer(Class<T> documentClass, JsonSerializer<T> jsonSerializer) {
        serializerMap.put(documentClass, jsonSerializer);
    }

    public void addDeserializer(Class<T> documentClass, JsonDeserializer<T> jsonDeserializer) {
        deserializerMap.put(documentClass, jsonDeserializer);
    }

    public Map<Class<T>, JsonSerializer<T>> getSerializerMap() {
        return serializerMap;
    }

    public Map<Class<T>, JsonDeserializer<T>> getDeserializerMap() {
        return deserializerMap;
    }
}
